Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support object style hooks #9634

Merged
merged 21 commits into from
Aug 22, 2022
Merged

feat: support object style hooks #9634

merged 21 commits into from
Aug 22, 2022

Conversation

antfu
Copy link
Member

@antfu antfu commented Aug 11, 2022

Description

Vite support for rollup/rollup#4600

Additional context

This PR should await rollup/rollup#4600 to get shipped and probably should release as a minor version bump.

Progress

  • Dev plugin container support for object hooks
  • Plugin format validation in dev? (e.g. missing handler or not function etc.). We don't have it previously.
  • Object hooks for Vite extended hooks (configureServer, configResolved, etc).
  • Align interface of transformIndexHtml - feat: align object interface for transformIndexHtml hook #9669

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@patak-dev patak-dev added the p3-significant High priority enhancement (priority) label Aug 11, 2022
package.json Outdated Show resolved Hide resolved
@antfu antfu marked this pull request as ready for review August 14, 2022 15:02
@antfu
Copy link
Member Author

antfu commented Aug 14, 2022

This one it ready

} as Plugin['transform']
} else {
return handler
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is worth extracting a helper for these three functions to avoid repeating the function or object handling?

}
}
await Promise.all(parallelPromises)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat. Not for this PR, but a helper like this one for hookSequential could be good too.

@patak-dev
Copy link
Member

Looks great! I think we should merge this in 3.1 as you suggest. We shouldn't restrict the rollup version in a patch. It will also help plugin authors with their required ranges.
We have a few PRs from @bluwy in the pipeline, maybe we could start a beta for 3.1 soon? It has been one month since the 3.0 release, and things look stable enough.

@patak-dev patak-dev added this to the 3.1 milestone Aug 14, 2022
zmrl010 added a commit to boatproject/editor that referenced this pull request Aug 17, 2022
based on recent [recent changes](rollup/rollup#4600) and upcoming [PR](vitejs/vite#9634)
@patak-dev patak-dev merged commit 757a92f into main Aug 22, 2022
@patak-dev patak-dev deleted the feat/plugin-object-hooks branch August 22, 2022 09:51
await Promise.all([
...resolved
.getSortedPluginHooks('configResolved')
.map((hook) => hook(resolved)),
Copy link
Member

@csr632 csr632 Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this inside the hook no loger points to the plugin object:
#10031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-significant High priority enhancement (priority)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants